package com.example.shop.ov;

import com.example.shop.shops.domain.Employee;
import com.example.shop.shops.domain.Shop;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.Date;


@Data
public class ShopOv {
    @NotBlank(message = "店铺名称不能为空！")
    private String name;
    @NotBlank(message = "电话不能为空！")
    private String tel;
    @NotBlank(message = "店铺名称不能为空！")
    private String address;

    private String logo;
    @Valid
    private AdminOv admin;

    public Shop getShop() {
        return Shop.builder()
                .name(this.getName())
                .tel(this.getTel())
                .address(this.getAddress())
                .logo(this.getLogo())
                .registertime(new Date())
                .state(0)
                .build();

    }
    public Employee getEmp() {
        Employee employee = new Employee();
        BeanUtils.copyProperties(admin, employee);
        employee.setAge(18);
        employee.setState(1);
        return employee;
    }
}
